package com.amorcloud.pig.adapter;

import android.content.Context;
import android.graphics.Color;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.amorcloud.pig.R;
import com.amorcloud.pig.bean.CheckBean;

import java.util.List;

public class CheckDataAdapter extends BaseAdapter {
    List<String> list;
    Context mContext;
    LayoutInflater inflater;

    public CheckDataAdapter(Context context, List<String> beans) {
        list = beans;
        mContext = context;
        inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if(convertView == null) {
            convertView = inflater.inflate(R.layout.item_check_data, null);
            viewHolder = new ViewHolder();
            viewHolder.data1 = convertView.findViewById(R.id.check_data1);
            viewHolder.data2 = convertView.findViewById(R.id.check_data2);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }

        viewHolder.data1.setText(String.valueOf(position + 1));
        viewHolder.data2.setText(list.get(position));
        return convertView;
    }

    private class ViewHolder{
        TextView data1, data2;
    }

    public void setData(List<String> beans) {
        list = beans;
        notifyDataSetChanged();
    }
}
